package org.robotfish.utils;

import static org.junit.Assert.*;

import org.ejml.simple.SimpleMatrix;
import org.junit.Test;

public class CFDTriangleTest {

	@Test
	public void test() {
		
		SimpleMatrix a = new SimpleMatrix(new double[][] {{1},{0},{0}}); 
		SimpleMatrix b = new SimpleMatrix(new double[][] {{0},{1},{0}}); 
		SimpleMatrix c = new SimpleMatrix(new double[][] {{0},{0},{1}});
		
		assertTrue(CFDTriangle.crossProduct(a, b).isIdentical(c, 1E-9));

		a = new SimpleMatrix(new double[][] {{1},{1},{0}}); 
		b = new SimpleMatrix(new double[][] {{-1},{1},{0}}); 
		c = new SimpleMatrix(new double[][] {{0},{0},{2}});
//		CFDTriangle.crossProduct(a, b).print();
		
		assertTrue(CFDTriangle.crossProduct(a, b).isIdentical(c, 1E-9));
		
		a = new SimpleMatrix(new double[][] {{0.129},{-0.923},{0.627}}); 
		b = new SimpleMatrix(new double[][] {{-1.812},{0.231},{0.713}}); 
		c = new SimpleMatrix(new double[][] {{-0.80294},{-1.2281},{-1.64268}});
//		CFDTriangle.crossProduct(a, b).print();
		
		assertTrue(CFDTriangle.crossProduct(a, b).isIdentical(c, 1E-3));
	}

}
